<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .show {
            width: 200px;
            height: 200px;
            background-color: rebeccapurple;
        }
        .hide {
            width: 200px;
            height: 200px;
            background-color: black;
        }
    </style>
</head>

<body>
    <div id="div">
        <!-- v-bind:使得属性后的值也变成一个表达式 -->
        <input type="text" placeholder="请输入年龄" v-model="age">
        <a :href="age>=18?url1:url0">{{age>=18?'大佬请进':'小孩子来这边'}}</a>

        <!-- 开关灯 -->
        <div>
            <button @click="isOn = !isOn">{{isOn?'关灯':'开灯'}}</button>
            <!-- <div :class="isOn?'show':'hide'"></div> -->
            <div :style="{'background-color':isOn?'yellow':'black','width':'200px','height':'200px'}"></div>

        </div>


    </div>

    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
    <script>
        const app = Vue.createApp({
            data: function () {
                return {
                    isOn: false,
                    age: 0,
                    url0: 'https://www.4399.com',
                    url1: 'https://www.taobao.com'
                }
            },

        }).mount('#div');
    </script>

</body>

</html>